package com.company.word.dao;



import com.company.word.pojo.Register;
import com.company.word.utils.JDBCUtils;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.SQLException;


public class RegisterDAOImpl implements IRegisterDAO{


	@Override
	public int insert(Register r) throws SQLException {
		String sql="insert into user values(null,?,?)";
		Connection conn= JDBCUtils.getConnection();
		PreparedStatement stmt=conn.prepareStatement(sql);
		stmt.setString(1,r.getUsername());
		stmt.setString(2,r.getPassword());
		int result;
		try{
			result=stmt.executeUpdate();}
		catch (SQLException throwables) {
			throwables.printStackTrace();
			result=-1;
		}
		System.out.println("影响行数"+result);
		JDBCUtils.destory(conn,stmt,null);
		return result;
	}
}
